﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class ACLJ_ACLJ_2 : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            //if (Request.QueryString.HasKeys())

            if (Request.QueryString["listid"] != null)
                Session["listid"] = Request.QueryString["listid"];
            else
                Session["listid"] = 1; //

            if (Request.QueryString["dnis"] != null)
                Session["dnis"] = Request.QueryString["dnis"];
            else
                Session["dnis"] = "2144324713";

            if (Request.QueryString["servername"] != null)
                Session["servername"] = Request.QueryString["servername"];
            else
                Session["servername"] = "COGSQL";

            if (Request.QueryString["projectname"] != null)
                Session["projectname"] = Request.QueryString["projectname"];
            else
                Session["projectname"] = "ACLJ";
            if (Request.QueryString["campaignname"] != null)
                Session["campaignname"] = Request.QueryString["campaignname"];
            else
                Session["campaignname"] = "ACLJ";
            if (Request.QueryString["agentid"] != null)
                Session["agentid"] = Request.QueryString["agentid"];
            else
                Session["agentid"] = 66319;
            if (Request.QueryString["agentfirst"] != null)
                Session["agentfirst"] = Request.QueryString["agentfirst"];
            else
                Session["agentfirst"] = "TestFirst";
            if (Request.QueryString["agentlast"] != null)
                Session["agentlast"] = Request.QueryString["agentlast"];
            else
                Session["agentlast"] = "TestLast";

            Session["App"] = new DataAccess();

            ddDonationType.SelectedValue = "1"; //Initilize drop down list to CC donation
            txtDonationAmt.Text = ""; //Initialize Donation Amt to Nothing

            //MyIFrame.Attributes["src"] = "https://scripting.callport.net/?CTIMapID=990057890&CallID=" + "8013931635";
            MyIFrame.Attributes["src"] = "http://www.focusservices.com";

            //WebWizard.ActiveStepIndex = 0;

            ((DataAccess)Session["App"]).PutCallData("ServerName", Session["servername"].ToString());
            ((DataAccess)Session["App"]).PutCallData("webusercode", "XX");
            ((DataAccess)Session["App"]).CommitCallData();

        }
        else
        {

        }
    }
    protected void btnSaveDonation_Click(object sender, EventArgs e)
    {
        lblErrorMsg.Visible = true;
        if (Convert.ToDecimal(txtDonationAmt.Text) > 0)
        {
            ((DataAccess)Session["App"]).PutCallData("PaymentType", ddDonationType.SelectedValue);
            ((DataAccess)Session["App"]).PutCallData("PaymentAmount", txtDonationAmt.Text);
            if (ddDonationType.SelectedValue == "1")
            {
                ((DataAccess)Session["App"]).PutCallData("webusercode", "05");
            }
            else
            {
                ((DataAccess)Session["App"]).PutCallData("webusercode", "04");
            }

            ((DataAccess)Session["App"]).CommitCallData();
            lblErrorMsg.Text = "Successfully Entered Donation Data";

            //Spawn inContact Script to set the agent state back to available for the agent 
            System.Net.WebRequest req = System.Net.HttpWebRequest.Create("https://inlogin.com/webmanager/incontrol/SpawnScriptOnCluster.aspx?script=Focus_ActivateAgent&bus_no=4528620&skill_no=35497&p1=" + Session["agentid"] + "&p2=&p3=&p4=&p5=&Guid=6319aeba-e66e-478a-bfbc-fcba204c9183");
            req.Method = "GET";
            System.Net.WebResponse res = req.GetResponse();
            res.Close();
            Response.Redirect("./ACLJ_DispositionComplete.aspx");

        }
        else
        {

            lblErrorMsg.Text = "Error, please enter a valid Donation Amount";
        }

    }
}